<template>
	<view class="msg-list">
		<view class="msg-item">
			<view class="item-left">
				<text class="item-name">专业</text>
				<input class="item-input" placeholder="请输入" v-model="idDesc" placeholder-class="input-placeholder" type="text">
			</view>
		</view>

		<view class="submit-btn-wrap" :disabled="btnDisabled">
			<largeBtn @btnClk="submit">确认</largeBtn>
		</view>

		<view class="selection-list" v-show="positionListShow">
			<view class="selection-tips">您也可以通过以下列表选择</view>
			<view class="selection-item" v-for="(item,index) in identityDesc" :key="index" @tap="selectPos(item)">
				<text class="selection-name">{{item.value}}</text>
				<image class="selection-arrow" src="../../static/rightTriangleArrow.png"></image>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState
	} from "vuex"
	export default {
		computed: {
			...mapState(['identityDesc', 'newEvaluate','tempIdentityDesc']),
			positionListShow() {
				return this.identityDesc.length > 0
			},
			btnDisabled(){
				return  !this.idDesc
			}
		},
		onLoad(options) {
		   this.pageType = options.type * 1 || 1  // 1:填写用户信息时  2：新增点评时
		   if(this.pageType == 2){
			   this.idDesc = this.newEvaluate.identityDesc 
		   }else{
			  this.idDesc = this.tempIdentityDesc 
		   }
		},
		data() {
			return {
				idDesc: ''
			}
		},

		methods: {
			selectPos(item) {
				this.idDesc = item.value
				if(this.pageType == 2){
					this.$store.commit('updateNewEvaluate', {
						identityDesc: this.idDesc
					})
				}else{
					this.$store.commit('setTempIdentityDesc', this.idDesc)
				}
				uni.navigateBack()
			},
			submit(){
				if(this.pageType == 2){
					this.$store.commit('updateNewEvaluate', {
						identityDesc: this.idDesc
					})
				}else{
					this.$store.commit('setTempIdentityDesc', this.idDesc)
				}
				uni.navigateBack()
			}
		}
	}
</script>

<style>
	page {
		background-color: #F3F7FD;
	}
</style>
<style lang="less">
	.msg-list {
		padding: 30rpx 40rpx;
		padding-bottom: 140rpx;

		.msg-item {
			background: #FFFFFF;
			box-shadow: 0 4rpx 8rpx 0 rgba(218, 227, 248, 0.5);
			border-radius: 10rpx;
			display: flex;
			justify-content: space-between;
			padding: 30rpx;
			margin-bottom: 40rpx;

			.item-left {
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.item-name {
					font-size: 36rpx;
					font-weight: 500;
					color: #333333;
					line-height: 50rpx;
					margin-bottom: 20rpx;
				}

				.item-input {
					font-size: 32rpx;
					font-weight: 400;
					color: #666;
					line-height: 44rpx;
					width: 500rpx;
				}

				.input-placeholder {
					color: #999;
				}
			}

		}
	}

	.selection-list {
		background: #FFFFFF;
		box-shadow: 0 4rpx 8rpx 0 rgba(218, 227, 248, 0.5);
		border-radius: 10rpx;
		padding: 30rpx;
		margin-bottom: 40rpx;

		.selection-tips {
			font-size: 28rpx;
			font-weight: 400;
			color: #999;
			line-height: 40rpx;
			margin-bottom: 16rpx;
		}

		.selection-item {
			height: 120rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 2rpx solid rgba(51, 153, 255, 0.3);

			.selection-name {
				font-size: 36rpx;
				font-weight: 400;
				color: #333333;
				line-height: 50rpx;
			}

			.selection-arrow {
				width: 32rpx;
				height: 32rpx;

			}
		}
	}

	.submit-btn-wrap {

		width: 670rpx;
		margin-bottom: 40rpx;
	}
</style>
